package com.twu.biblioteca;

import java.io.PrintStream;

public class BibliotecaApp {

    private final PrintStream out;

    public BibliotecaApp(PrintStream printStream) {
        this.out = printStream;
    }

    protected void printWelcomeMessage() {
        out.print("Welcome to Biblioteca!\n");
    }

    public static void main(String[] args) {

        new BibliotecaApp(System.out).printWelcomeMessage();

        BookManager bibliotecaBookManager = new BookManager();
        bibliotecaBookManager.populateListWithBooks();

        MovieManager bibliotecaMovieManager = new MovieManager();
        bibliotecaMovieManager.populateListWithMovies();

        UserAccountManager bibliotecaUserAccountManager = new UserAccountManager();
        bibliotecaUserAccountManager.populateListWithUsers();

        MainMenu bibliotecaMainMenu = new MainMenu();
        bibliotecaMainMenu.showMainMenu();

        while (true) {

            int userChoice = bibliotecaMainMenu.retrieveUserMenuChoice("\nPlease select your preferred option: ");

            bibliotecaMainMenu.runMenuSelection(userChoice, bibliotecaBookManager, bibliotecaMovieManager, bibliotecaUserAccountManager);

            System.out.print("\nWhat else would you like to do?\n");
            bibliotecaMainMenu.runMainMenu();
        }
    }
}